<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
        #red{background:red;width:120px;height:120px;}
        #green{background:green;width:80px;height:80px;}
        #yellow{background:yellow;width:40px;height:40px;}
      </style>
<body>
    <button id="btn" class="btnClass">获取event对象</button>
    <script>
        var btn = document.getElementById('btn');
        btn.onclick = function(e){
            var obj = event.target || window.event.srcElement;
            console.log(obj.nodeName);
            console.log(obj.id);
            console.log(obj.className);
            console.log(obj.innerText);
        };
    </script>
    <div id="red">
        <div id="green">
            <div id="yellow"></div>
        </div>
    </div>
    <script>
        var red = document.getElementById('red');
        var green = document.getElementById('green');
        var yellow = document.getElementById('yellow');
        red.onclick = function(){ console.log('red');};
        green.onclick = function(){ console.log('green');};
        yellow.onclick = function(){ console.log('yellow');};
    </script>
</body>
</html>